<template>
    <div id="m">
        <div class="t">新增管理员</div>
        <el-form ref="form" :model="admin" label-width="80px">
        <el-form-item label="登录名称" style="margin-bottom: 50px;">
            <el-input v-model="admin.username"></el-input>
        </el-form-item>
        <el-form-item label="登录密码">
            <el-input v-model="admin.password"></el-input>
        </el-form-item>
        <el-form-item style="margin-top: 40px;">
            <el-button type="primary" @click="addAdmin" style="margin-top: 20px; margin-right: 70px;">添加</el-button>
            <el-button type="warning" @click="cancel">取消</el-button>
        </el-form-item>
        </el-form>
    </div>
</template>

<script>
    export default {
        name:"AddCourse",
        data() {
            return {
                admin:{
                    username:"",
                    password:"",
                },
            }
        },
        created() {
            this.getData();
        },
        methods: {
            addAdmin() {
                this.$axios({
                    method:'post',
                    url:'http://localhost:8081/login/add',
                    data:this.admin
                }).then(res=>{
                    this.cancel();
                    console.log(res.data);
                }).catch(err=>{
                    console.log(err);
                })
            },
            cancel() {
                this.$router.replace({
                    path:'/home', 
                })
            },
        }
    }
</script>

<style>
    #m {
        width: 700px;
        height: 500px;
        margin: 150px auto;
        border: 1px rgb(190, 190, 190) solid;
        border-radius: 20px;
        box-shadow: 10px 10px 5px rgba(205, 203, 203, 0.9);
        z-index: 40;
        position: absolute;
        top: 80px;
        left: 500px;
        background-color: #ffffffee;
        padding-top: 40px;
    }
    .t {
        font-weight: 800;
        margin: 35px 0px 70px 0px;
        font-size: 30px;
    }
</style>